/*package com.dai.chun.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.log4j.*;

import com.dai.chun.dbc.DBManager;




*//**
 * 子类中对数据库操作的相同方法将在这个类中运行，不相同的方法通过抽象方法让子类完成
 * 
 *//*
public abstract class BaseTablesOperater {
	protected Connection conn;
	protected DBManager manager = DBManager.getInstance();
	public static Logger logger = Logger.getLogger(BaseTablesOperater.class);
	public BaseTablesOperater() {

	}

	public BaseTablesOperater(Connection conn) {
		this.conn = conn;
	}

	// 计算自定参数的总行数
	public int doCountRow(String sql, List<Object> args) throws SQLException {
		int flag = -1;
		PreparedStatement pstm = null;
		ResultSet rs = null;

		try {
			pstm = manager.createPstmt(conn, sql);
			for (int i = 0; i < args.size(); i++) {
				pstm.setObject(i + 1, args.get(i));
			}
			rs = pstm.executeQuery();
			rs.next();
			flag = rs.getInt(1);
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		} finally {
			manager.close(rs, pstm, conn);
		}
		return flag;
	}

	// 用于查询记录的总条
	public int doSelectCount(String sql) throws SQLException {
		int count = 0;
		PreparedStatement pstm = null;
		ResultSet rs = null;
		try {
			pstm = manager.createPstmt(conn, sql);
			rs = pstm.executeQuery();
			rs.next();
			count = rs.getInt(1);
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		} finally {
			manager.close(rs, pstm, conn);
		}
		return count;
	}

	// 子类在执行增、删、改时将调用这个方法
	public boolean doOperater(String sql, List<Object> args) {
		boolean flag = false;
		PreparedStatement pstmt = null;
		pstmt = manager.createPstmt(conn, sql);
		try {
			for (int i = 0; i < args.size(); i++) {
				pstmt.setObject(i + 1, args.get(i));
			}
			pstmt.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			manager.close(conn, pstmt);
		}
		flag = true;
		return flag;
	}
	public int doSelectId(String sql,List<Object> args) throws SQLException {
		int id=0;
		PreparedStatement pstmt = null;
		pstmt = manager.createPstmt(conn, sql);
		ResultSet res = null;
		try {
			for(int i=0; i<args.size(); i++) {
					pstmt.setObject(i+1, args.get(i));
			}
			res = pstmt.executeQuery();
			while(res.next()) {
				id = res.getInt("uncleID");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			manager.close(conn, pstmt);
		}
		return id;
	}
	// 子类执行查询操作时将调用这个方法
	public List<Object> doSelect(String sql, List<Object> args) {
		List<Object> list = new ArrayList<Object>();
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		pstmt = manager.createPstmt(conn, sql);
		try {
			if (args != null) {
				for (int i = 0; i < args.size(); i++) {
					pstmt.setObject(i + 1, args.get(i));
				}
			}

			rs = pstmt.executeQuery();
			list = mapRow(rs);

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			manager.close(rs, pstmt, conn);
		}
		return list;
	}
	public List<Object> doSelectUncle (String sql, List<Object> args) {
		List<Object> list = new ArrayList<Object>();
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		pstmt = manager.createPstmt(conn, sql);
		try {
			if (args != null) {
				for (int i = 0; i < args.size(); i++) {
					pstmt.setObject(i + 1, args.get(i));
				}
			}
			rs = pstmt.executeQuery();
			while (rs.next()) {
				Uncle uncle = new Uncle();
				uncle.setUncleID(rs.getInt("uncleID"));
				uncle.setUncleName(rs.getString("uncleName"));
				uncle.setPhone(rs.getString("phone"));
				uncle.setChildID(rs.getInt("childID"));
				uncle.setHelpStatus(rs.getString("helpStatus"));
				uncle.setGoods(rs.getString("goods"));
				uncle.setPreDate(rs.getString("preDate"));
				uncle.setLaterDate(rs.getString("laterDate"));
				list.add(uncle);
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			manager.close(rs, pstmt, conn);
		}
		return list;
	}
	
	//do transaction
	public boolean doUpdateTransaction(Map<String,List> map) throws Exception{
		boolean flag = true;
		PreparedStatement pstmt = null;
		String sql = "";
		try {
			conn.setAutoCommit(false);
			Iterator itr = map.entrySet().iterator();
			while(itr.hasNext()) {
				Map.Entry<String, List> entry = (Entry<String, List>) itr.next();
				sql = entry.getKey();
				List list = entry.getValue();
				pstmt = manager.createPstmt(conn, sql);
				for(int i=0; i<list.size(); i++) {
						pstmt.setObject(i+1, list.get(i));
				}
				
				pstmt.executeUpdate();
			}
			conn.commit();
			conn.setAutoCommit(true);
		} catch (SQLException e) {
			flag = false;
			e.printStackTrace();
			conn.rollback();
			conn.setAutoCommit(true);
		}finally {
			manager.close(conn, pstmt);		//增加了conn
		}
		return flag;
	}

	// 辅助分页查询所需信息行数
	public int doSelectCount(String sql, List<Object> args) {
		int count = -1;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		pstmt = manager.createPstmt(conn, sql);
		try {
			for (int i = 0; i < args.size(); i++) {
				pstmt.setObject(i + 1, args.get(i));
			}
			rs = pstmt.executeQuery();
			while (rs.next()) {
				count = rs.getInt(1);
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			manager.close(rs, pstmt, conn);
		}
		return count;
	}

	// 将数据库中的数据转化为子类对象
	public abstract List<Object> mapRow(ResultSet rs) throws Exception;
	

	// 将子类的对象转化为一个参数集合
	public abstract List<Object> getArgsList(Object obj);
}
*/